<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0">
		<title>贝达教育</title>
		<link href="../../css/style.css" rel="stylesheet" type="text/css" />
		<link href="../../css/mui.min.css" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" href="../../css/swiper.min.css">
		<link rel="stylesheet" href="../../css/certify.css">
		<link rel="stylesheet" href="../../src/iconfont/iconfont.css">
		<link rel="stylesheet" href="../css/animated.css">
		<style>
			* {
				outline: none;
				webkit-focus-ring-color: rgba(0, 0, 0, 0);
				-webkit-tap-highlight-color: transparent;
				-webkit-touch-callout: none;
			}
			
			#schools {
				background: #fff;
			}
			
			.IndOneP {
				position: relative;
			}
			
			.chengqu {
				font-size: 12px;
				float: left;
				/* margin-right: 10px; */
			}
			
			.bg.mui-media-object {
				width: 1.8rem;
				height: 1.5rem;
			}
			
			.IndOneE span {
				display: inline-block;
				height: 18px;
				line-height: 18px;
			}
			/* input[type='search'] {
            border: solid 1px #e9e9e9;
            border-radius: 20px;
        } */
			
			.guanzhu {
				/* border: solid 1px #25aae3; */
				position: absolute;
				right: 0px;
				top: 0px;
				font-size: 12px;
				width: 60px;
				padding-top: 1px;
				padding-bottom: 1px;
				text-align: center;
				color: #ffffff;
				background-color: #FECF0E;
				border-radius: 100px;
				border-top-left-radius: 0px;
			}
			
			.IndOneM {
				margin-top: 5px;
			}
			
			.mui-show-loading {
				position: fixed;
				padding: 5px;
				width: 120px;
				min-height: 120px;
				top: 45%;
				left: 50%;
				margin-left: -60px;
				background: rgba(0, 0, 0, 0.6);
				text-align: center;
				border-radius: 5px;
				color: #FFFFFF;
				visibility: hidden;
				margin: 0;
				z-index: 2000;
				-webkit-transition-duration: .2s;
				transition-duration: .2s;
				opacity: 0;
				-webkit-transform: scale(0.9) translate(-50%, -50%);
				transform: scale(0.9) translate(-50%, -50%);
				-webkit-transform-origin: 0 0;
				transform-origin: 0 0;
			}
			
			.mui-show-loading.loading-visible {
				opacity: 1;
				visibility: visible;
				-webkit-transform: scale(1) translate(-50%, -50%);
				transform: scale(1) translate(-50%, -50%);
			}
			
			.mui-show-loading .mui-spinner {
				margin-top: 24px;
				width: 36px;
				height: 36px;
			}
			
			.mui-show-loading .text {
				line-height: 1.6;
				font-family: -apple-system-font, "Helvetica Neue", sans-serif;
				font-size: 14px;
				margin: 10px 0 0;
				color: #fff;
			}
			
			.mui-show-loading-mask {
				position: fixed;
				z-index: 1000;
				top: 0;
				right: 0;
				left: 0;
				bottom: 0;
			}
			
			.mui-show-loading-mask-hidden {
				display: none !important;
			}
			
			.swiper-slide img,
			#certify .swiper-slide {
				height: auto!important;
			}
			
			.modelbg {
				width: 100%;
				position: fixed;
				top: 0%;
				left: 0px;
				z-index: 1000;
				background-color: #ffffff;
				text-align: center;
			}
			
			.modelbg embed {
				width: 100%;
			}
			
			.fade-enter-active,
			.fade-leave-active {
				transition: opacity .5s;
			}
			
			.fade-enter,
			.fade-leave-to
			/* .fade-leave-active below version 2.1.8 */
			
			{
				opacity: 0;
			}
			
			[v-cloak] {
				display: none;
			}
			/* .mui-bar-nav~.mui-content .mui-pull-top-pocket {
            top: 290px !important;
        } */
		</style>
	</head>

	<body>
		<div id="schools"> 
		<transition name="fade">
            <!-- v-show="shows" -->
            <div v-show="shows" class="modelbg" :style="{height:winHeight+'px',paddingTop:(winHeight-195)/2+'px'}">
                <!-- <img src="../../src/img/loading2.gif" style="width: 260px;height: 195px;margin-left: auto;margin-right: auto;" alt=""> -->
                <embed src="../../src/img/loading.svg" width="300" height="100" type="image/svg+xml" pluginspage="http://www.adobe.com/svg/viewer/install/" />
            </div>
        </transition>
			<div id="pullrefresh" class="mui-content mui-scroll-wrapper list-frame" style="background: #fff!important;">

				<div class="mui-scroll">
					<!--banner-开始-->
					<div class="search" id="schoolsearch">
						<!-- <input id="txtkey" placeholder="请输入检索内容" value="" class="searchI" />
            <input type="text" placeholder="请输入检索内容"> -->
						<div id="txtkey" class="searchI">
							<span style="font-size: 12px;">请输入检索内容</span>
							<span class="newIconFont">| <span>搜索</span> </span>
						</div>
					</div>
					<div id="certify">
						<div class="swiper-container">
							<div class="swiper-wrapper">
							</div>
						</div>
						<div class="swiper-pagination"></div>
					</div>
					<!--banner-结束-->

					<!--腰线-开始-->
					<div class="IndMenu">
						<a v-for="(type,index) in types" class="IndMenuA fl" @tap="openlist(type)"><i :class="'IndMenuI IndMenuI'+(index+1)"></i>
							<p>{{type.name}}</p>
						</a>
						<!--div class="IndMenuB">
        	<div class="youer fl" @tap="openlist(705)"><img src="../../images/flow_03.jpg" /><span>幼儿园</span></div> 
        	<div class="xueqian fr" @tap="openlist(706)"><img src="../../images/home_03.jpg" /><span>学前班</span></div>
        	<div class="clear"></div>
   	   </div-->
						<div class="clear"></div>
					</div>
					<div class="clear"></div>

					<!--腰线-开始-->

					<!--育儿课程-开始-->

					<div id="recommend-list">
						<div class="IndOne"> 
							<!--div class="IndTit">第二课堂</div-->
							<div class="IndOneT" id="IndOneT">
								<a href="JavaScript:;" title="IndO1" class="IndOneTo fl" @tap="distance(recommend)">距离最近</a>
								<a href="JavaScript:;" title="IndO2" class="fl" @tap='pingfen(recommend)'>评分最高</a>
								<a href="JavaScript:;" title="IndO3" class="fl" @tap='follow(recommend)'>关注最多</a>
								<div class="clear"></div>
							</div> 
							<!--距离最近 --> 
							<div class="IndOneN IndO1" style=" display:block;">
								<div class="IndOneA" v-for="(item,index) in recommend" @tap="opendetail(item)" style="width: 100%;">
									<div class="IndOneI">
										<!-- <div class="bg mui-media-object" :style="{backgroundImage:'url(' + item.pic + ')'}"></div> -->
										<img :src="item.pic" alt="">
									</div>
									<div class="IndOneP">
										<div class="IndOneB"><span class="IndOneBtitle">{{item.institution_name}}</span>
											<span class="guanzhu" v-if="item.code_status==0" @tap="guanzhu(item,event)">关注</span>
											<span class="guanzhuOr guanzhu" v-if="item.code_status==1" @tap="guanzhu(item,event)">已关注</span>
										</div>
										<div class="IndOneC">
											<div class="IndOnSty" style="display: flex;flex-wrap: wrap;">
												<!-- <img src="../../images/star.png" class="fl" v-for="(star,index) in 5" v-if="index<=item.comment-1" /> -->
												<span class="iconfont icon-favorfill" style="font-size: 13px;color: #FECF0E;" v-for="(star,index) in item.comment" v-if="index<=item.comment-1"></span>
												<span class="iconfont icon-favorfill" style="font-size: 13px;color: #e9e9e9;" v-for="(star,index) in 5-item.comment"></span>
												<span style="margin-left: 3px;">{{item.comment}}分</span> <span style="margin-left: 5px;margin-right: 5px;"> | </span> <span class="IndOeye">{{item.views}}</span>
											</div>

										</div>
										<!-- <div class="clear"></div> -->
										<div class="IndOneE"><span v-for="label in item.type">{{label.dict_field}}</span></div>
										<div class="IndOneM">
											<div class="chengqu">{{item.institution_district}} | </div><span class="fr" style="margin-left: 3px;">{{item.distance}}</span></div>
										<div class="clear"></div>
									</div>
									<!-- <div class="clear"></div> -->
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<!--育儿课程-结束-->
		</div>
		<div class="loadingbox">

		</div>
	</body>

	<script type="text/javascript" src="../../js/jquery-1.8.3.min.js"></script>
	
	<script src="../../js/idangerous.swiper.min.js"></script>
	<script src="../../js/mui.min.js"></script>
	<script src="../../js/vue.min.js"></script>
	<script src="../../js/app.js"></script>
	<script src="../../js/swiper.min.js"></script>
	<script src="../../js/token.js"></script>
	<script src="../../js/index.js"></script>
	<script>
		/*(function($, window) { 
				        //显示加载框
				        $.showLoading = function(message, type) {
				            if ($.os.plus && type !== 'div') {
				                $.plusReady(function() {
				                    plus.nativeUI.showWaiting(message);
				                });
				            } else {
				                var html = '';
				                html += '<i class="mui-spinner mui-spinner-white"></i>';
				                html += '<p class="text">' + (message || "数据加载中") + '</p>';

				                //遮罩层
				                var mask = document.getElementsByClassName("mui-show-loading-mask");
				                if (mask.length == 0) {
				                    mask = document.createElement('div');
				                    mask.classList.add("mui-show-loading-mask");
				                    document.body.appendChild(mask);
				                    mask.addEventListener("touchmove", function(e) {
				                        e.stopPropagation();
				                        e.preventDefault();
				                    });
				                } else {
				                    mask[0].classList.remove("mui-show-loading-mask-hidden");
				                }
				                //加载框
				                var toast = document.getElementsByClassName("mui-show-loading");
				                if (toast.length == 0) {
				                    toast = document.createElement('div');
				                    toast.classList.add("mui-show-loading");
				                    toast.classList.add('loading-visible');
				                    document.body.appendChild(toast);
				                    toast.innerHTML = html;
				                    toast.addEventListener("touchmove", function(e) {
				                        e.stopPropagation();
				                        e.preventDefault();
				                    });
				                } else {
				                    toast[0].innerHTML = html;
				                    toast[0].classList.add("loading-visible");
				                }
				            }
				        };
 
				        //隐藏加载框
				        $.hideLoading = function(callback) {
				            if ($.os.plus) {
				                $.plusReady(function() {
				                    plus.nativeUI.closeWaiting();
				                });
				            }
				            var mask = document.getElementsByClassName("mui-show-loading-mask");
				            var toast = document.getElementsByClassName("mui-show-loading");
				            if (mask.length > 0) {
				                mask[0].classList.add("mui-show-loading-mask-hidden");
				            }
				            if (toast.length > 0) {
				                toast[0].classList.remove("loading-visible");
				                callback && callback();
				            }
				        }
				    })(mui, window);*/

		/*//育儿课程
		jQuery(document).ready(function($) {
			//育儿课程
			$('.IndOneT a').click(function() {
				if(!$(this).hasClass('IndOneTo')) {
					$('.IndOneT a').removeClass('IndOneTo');
					$(this).addClass('IndOneTo');

				}
			})

		})*/
		
		var jd = '';
		var wd = '';
		var uid = "";
		var favoritestatus = 0;
		var point = '';
		var pages = 1;
		var contentWebview = null;
		//mui初始化，配置下拉刷新
		mui.init({
			swipeBack: false,
			pullRefresh: {
				container: '#pullrefresh',
				down: {
					callback: function() {
						pages = 1
						pulldownRefresh(pages)
					}
				},
				up: {
					contentrefresh: '正在加载...',
					callback: function() {
						pages++;
						pullupRefresh(pages)
					}
				}
			}

		});
		// mui.showLoading("正在加载..", "div");

		mui.plusReady(function() {
			if(window.plus && plus.networkinfo.getCurrentType() === plus.networkinfo.CONNECTION_NONE) {
				mui.openWindow({
						url: '../login.html',
						id: 'login',
						styles: {
							"render": "always",
							"popGesture": "hide",
							"bounce": "vertical"
						}, 
						
					});
			}
			var state = app.getState();
			var point = '';
			uid = state.userid;
			memberToken = state.memberToken;
			console.log(uid)
			//alert(memberToken)
			paradata = {
				uid: uid,
				memberToken: memberToken,
				page: pages,
			};
				var taba=document.getElementById('IndOneT').getElementsByTagName('a');
			for(var i=0; i < taba.length; i++){
				taba[i].index=i
				taba[i].addEventListener('tap',function(){
					for(var i=0; i < taba.length; i++){
						taba[i].classList.remove('IndOneTo')
					}
					this.classList.add('IndOneTo')
				})
			}
			
			/*setTimeout(function() {
			    mui.hideLoading();
			}, 2000)*/
			plus.push.addEventListener("receive", function(msg) {
				alert(msg)
			})
			plus.geolocation.getCurrentPosition(function getinfo(position) {
				var lat = position.coords.latitude; //获取经纬度
				var lng = position.coords.longitude;
				paradata.latitude = lat;
				paradata.longitude = lng;
				mui.ajax(Apiurl + 'index/institution_new', {
					data:paradata,
					type: "POST",
					dataType: "json",
					timeout:3000,//超时时间设置为1秒；  
					success:function(data, textStatus, xhr) {
					console.log(JSON.stringify(data.list))  
					if(data.list && data.list.length > 0) {
						schools.recommend = data.list;
						schools.shows = false;
						point = data.point;
						if(point) {
							plus.nativeUI.toast('恭喜您获得' + point + '积分', {
								verticalAlign: 'top'
							});
						}
						// alert(JSON.stringify(data)) 
						mui.fire(plus.webview.getWebviewById("pcenter"), "refreshpoint", {});
					}
					mui('#pullrefresh').pullRefresh().endPulldownToRefresh();
				},
				error:function(xhr, type, errorThrown){  
					mui.openWindow({
						url: '../login.html',
						id: 'login',
						styles: {
							"render": "always",
							"popGesture": "hide",
							"bounce": "vertical"
						}, 
						
					});
				}
				} 
				);
			});
			//轮播图
			mui.post(Apiurl + 'index/banner', {
				uid: uid,
				memberToken: memberToken,

			}, function(data) {
				console.log(JSON.stringify(data))
				var bannerHtml = '';
				for(var i = 0; i < data.length; i++) {
					bannerHtml += "<div class=\"swiper-slide\" onclick=\"banner_detail('" + data[i].banner_url + "','" + data[i].banner_title + "');\"><img src='" + data[i].banner_pic + "'></div>";
				}

				$(".swiper-wrapper").html(bannerHtml);
				certifySwiper = new Swiper('#certify .swiper-container', {
					loop: true,
					loopedSlides: 3,
					autoplay: true,
					autoplay: {
						disableOnInteraction: false,
					}
				})

			}, 'json');
			//分类按钮
			mui.post(Apiurl + 'index/dict', {
				uid: uid,
				memberToken: memberToken
			}, function(data) {
				//alert(JSON.stringify(data))
				schools.types = data;
			}, 'json');
			
			

			var curWebview;
			var backButtonPress = 0;
			var old_back = mui.back;
			//为您优选

			mui.back = function(event) {
				var adWebview = plus.webview.getWebviewById('ad_detail');
				if(adWebview) {
					adWebview.close();
				} else {
					backButtonPress++;
					if(backButtonPress > 1) {
						plus.runtime.quit();
					} else {
						plus.nativeUI.toast('再按一次退出应用');
					}
					setTimeout(function() {
						backButtonPress = 0;
					}, 1000);
					return false;
				}
			};
		});

		var schools = new Vue({
			el: '#schools',
			data: {
				banners: [], //顶部banner数据
				types: [], //分类数据
				recommend: [],
				winHeight: window.innerHeight,
				shows: true,
				showss: true
			},

			methods: {
				openlist: function(type) {
					var typeid = type.id
					if(type == 705 || type == 706) {
						typeid = type;
					}
					mui.openWindow({
						url: 'list.html',
						id: 'schoolslist',
						styles: {
							"render": "always",
							"popGesture": "hide",
							"bounce": "vertical"
						}, 
						extras:{
							type: "dict",
                       		typeid: typeid
						}
					});
					
				},
				guanzhu: function(item, event) {
					plus.webview.getWebviewById("monitor").reload(true);
					event.stopPropagation();
					var data = {
						uid: uid,
						code: item.code,
						memberToken: memberToken
					}
					if(item.code_status == 1) {
						item.code_status = 0;
						mui.post(Apiurl + 'index/institution', data, function(data) {
							if(data.status == "200") {
								plus.nativeUI.toast('取消成功', {
									verticalAlign: 'middle'
								});
							}
						}, 'json')

					} else {
						item.code_status = 1;

						mui.post(Apiurl + 'index/institution', data, function(data) {

							if(data.status == "200") {
								plus.nativeUI.toast('关注成功', {
									verticalAlign: 'middle'
								});
							}
						}, 'json')

					}

				},
				opendetail: function(item) {
					mui.openWindow({
						url: 'detail.html',
						id: 'schoolsdetail',
						extras: {
							instid: item.institution_id
						},
						createNew: true,

					});
				},
				follow: function() {
					pages = 1;
					paradata.comment = '';
					paradata.codes = "5";
					pulldownRefresh(pages)
				},
				distance: function() {
					pages = 1;
					paradata.comment = '';
					paradata.codes = '';
					pulldownRefresh(pages)
				},
				pingfen: function() {
					pages = 1;
					paradata.codes = '';
					paradata.comment = 5;
					pulldownRefresh(pages)
				}
			},
			created: function() {

			}
		});

		//下拉刷新
		function pulldownRefresh(pages) {
			if(window.plus && plus.networkinfo.getCurrentType() === plus.networkinfo.CONNECTION_NONE) {
				plus.nativeUI.toast('似乎已断开与互联网的连接', {
					verticalAlign: 'top'
				});
				return;
			}
			paradata.page = pages
			mui.post(Apiurl + 'index/institution_new', paradata, function(data) {
				if(data.list && data.list.length > 0) {
					schools.recommend = data.list;
					//alert(JSON.stringify(schools.recommend))
					schools.shows = false
					point = data.point;
					if(point) {
						plus.nativeUI.toast('恭喜您获得' + point + '积分', {
							verticalAlign: 'top'
						});
					}
					mui.fire(plus.webview.getWebviewById("pcenter"), "refreshpoint", {});
				}
				mui('#pullrefresh').pullRefresh().endPulldownToRefresh();
			}, 'json');
		}
		//上拉加载
		function pullupRefresh(pages) {
			paradata.page = pages;
			mui.post(Apiurl + 'index/institution_new', paradata, function(data) {
				if(pages <= data.pagecount) {
					if(data.list && data.list.length > 0) {
						schools.recommend = schools.recommend.concat(data.list);
					}
				}
				mui('#pullrefresh').pullRefresh().endPullupToRefresh();
			}, 'json');
		}
		//打开微信文章详情 
		function banner_detail(bannerurl, bannertitle) {
			mui.openWindow({
				url: bannerurl,
				id: 'ad_detail',
				styles: {
					"render": "always",
					"popGesture": "hide",
					"bounce": "vertical",
					"bounceBackground": "#efeff4",
					"titleNView": titleNView = { //详情页原生导航配置
						autoBackButton: true, //自动绘制返回箭头
						backgroundColor: '#fff', //导航栏背景色
						titleText: bannertitle, //导航栏标题
						titleColor: '#000', //文字颜色
						//coverage:"120px",
						//type: 'transparent', //透明渐变样式
						splitLine: { //底部分割线
							color: '#dfdfdf'
						}
					}
				}
			});
		}
		//刷新关注按钮
		window.addEventListener('refreshshcools', function(event) {
			schools.recommend.forEach(function(res) {
				if(res.institution_id == event.detail.msgid) {
					if(res.code_status == 1) {
						res.code_status = 0
					} else if(res.code_status == 0) {
						res.code_status = 1
					}
				}
			})

		});
		document.getElementById("schoolsearch").addEventListener('tap', function() {
			mui.openWindow({
				url: 'search.html',
				id: 'schoolsearch'
			});
		});
		/*document.getElementById("jpst").addEventListener('tap', function() {
			mui.openWindow({
				url: 'adlist.html',
				id: 'schoolslist',
				extras: {
					type: '1'
				},
				styles: {
					"render": "always",
					"popGesture": "hide",
					"bounce": "vertical",
					"bounceBackground": "#efeff4",
					"titleNView": titleNView = { //详情页原生导航配置
						autoBackButton: true, //自动绘制返回箭头
						backgroundColor: '#25aae3', //导航栏背景色
						titleText: '精品试听', //导航栏标题
						titleColor: '#F7F7F7', //文字颜色
						//coverage:"120px",
						//type: 'transparent', //透明渐变样式
						splitLine: { //底部分割线
							color: '#cccccc'
						}
					}
				}
			});
		});
		document.getElementById("xjzk").addEventListener('tap', function() {
			mui.openWindow({
				url: 'adlist.html',
				id: 'schoolslist',
				extras: {
					type: '2'
				},
				styles: {
					"render": "always",
					"popGesture": "hide",
					"bounce": "vertical",
					"bounceBackground": "#efeff4",
					"titleNView": titleNView = { //详情页原生导航配置
						autoBackButton: true, //自动绘制返回箭头
						backgroundColor: '#25aae3', //导航栏背景色
						titleText: '享尽折扣', //导航栏标题
						titleColor: '#F7F7F7', //文字颜色
						//coverage:"120px",
						//type: 'transparent', //透明渐变样式
						splitLine: { //底部分割线
							color: '#cccccc'
						}
					}
				}
			});
		});
		document.getElementById("fj").addEventListener('tap', function() {
			mui.openWindow({
				url: 'list.html',
				id: 'schoolslist',
				extras: {
					type: 'fj'
				}
			});
		});
		document.getElementById("sl").addEventListener('tap', function() {
			mui.openWindow({
				url: 'list.html',
				id: 'schoolslist',
				extras: {
					type: 'sl'
				}
			});
		});
		document.getElementById("rm").addEventListener('tap', function() {
			mui.openWindow({
				url: 'list.html',
				id: 'schoolslist',
				extras: {
					type: 'rm'
				}
			});
		});
		document.getElementById("gf").addEventListener('tap', function() {
			mui.openWindow({
				url: 'list.html',
				id: 'schoolslist',
				extras: {
					type: 'gf'
				}
			});
		});
		mui('.mui-scroll-wrapper').scroll({
			deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
		});
		var txtkey = document.getElementById('txtkey');
		//监听搜索按钮点击
		btnsearch.addEventListener('tap', function(event) {
			if(!txtkey.value) return false;
			mui.openWindow({
				url: 'search.html',
				id: 'momentssearch',
				extras: {
					keyword: txtkey.value
				}
			});
		});
		//监听回车事件
		txtkey.addEventListener('keyup', function(event) {
			if(!txtkey.value) return false;
			if(event.keyCode == 13) {
				mui.openWindow({
					url: 'search.html',
					id: 'momentssearch',
					extras: {
						keyword: txtkey.value
					}
				});
			}
		});*/
	</script>

</html>